package com.xdf.xzymanagementsystem.dao;

import com.mybatisflex.core.BaseMapper;
import com.xdf.xzymanagementsystem.entity.OrderMain;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.xdf.xzymanagementsystem.util.Example;
import org.apache.ibatis.annotations.Param;

/**
 * @Description : 由代码生成器生成
 * @Author : chanchaw
 * @Date :  2025-3-21 18:43:41
 */
@Repository
public interface OrderMainMapper extends BaseMapper<OrderMain> {
    //=================以上是自动生成的代码，自定义代码请写在下面==================
    @Select("CALL usp_order_detail_Page(#{sdate},#{edate},#{flag})")
    List<Map<String, Object>> selectAllDTO(Date sdate, Date edate, Integer flag);

    @Select("select * from order_main where id = #{id}")
    OrderMain selectById(Integer id);

    @Select("select * from order_main order by id desc limit 1")
    OrderMain selectMaxBillCode();

    @Select("select * from order_main where order_no = #{orderNo} order by id desc limit 1")
    OrderMain selectRepeatOrderNo(String orderNo);

    @Select("select order_no, client_id from order_main where state <> 2 and is_delete = 0 order by order_no")
    List<Map<String, Object>> selectAllOrderNo();

    @Select("select order_no, client_id from order_main where is_delete = 0 order by order_no")
    List<Map<String, Object>> selectAllOrderNo2();

    @Select("select order_no from order_main where client_id = #{id} order by id desc limit 1")
    OrderMain selectOneByClientId(Integer id);

    @Select("call usp_getclientordersum(#{sdate}, #{edate}, #{flag})")
    List<Map<String, Object>> selectAllsum(Date sdate, Date edate, int flag);

    @Select("call usp_order_main_Page(#{sdate}, #{edate}, #{flag})")
    List<Map<String, Object>> selectAllmain(Date sdate, Date edate, int flag);

    @Select("call usp_getclientorder_detail(#{orderNo})")
    List<Map<String, Object>> selectAlldetail(String orderNo);

//    int insertOrderMain(OrderMain orderMain);
}